﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Xml.Linq;
using System.Collections;
using System.Data.SqlClient;
using Server_NhaSach.DataAccess.HelperLayer;
using Server_NhaSach.BusinessLayer;
using System.Xml;
using Server_QuanLyNhaSach;

namespace Server_NhaSach.WCF_Interface
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Serviec_QLNhaSach" in code, svc and config file together.
    public class Serviec_QLNhaSach:IAdapter
    {
        #region "Khai báo các biến"
        private NhaCungCapBlo       ncc_blo = null;
        private PhieuDatHangNCCBlo  phieuDHNCC_blo = null;
        private NhanVienBlo         nhanvien_blo = null;
        private KhachHangBlo        khachhang_blo = null;
        private CTDatHangOnlineBlo  ctdathangOnline_blo = null;
        private CTKHDatHangBlo      ctKHDatHang_blo = null;
        private CTDieuChinhKhoBlo   ctDieuChinhKho_blo= null;
        private CTHDBanLeBlo        ctHDBanLe_blo = null;
        private CTHDBanSiBlo        ctHDBanSi_blo = null;
        private CTKHTraHangBlo      ctKHTraHang_blo = null;
        private CTPhanQuyenBlo      ctPhanQuyen_blo = null;
        private DatHangOnlineBlo    datHangOnline_blo = null;
        private FormBlo             form_blo = null;
        private HoaDonBanLeBlo      hDonBanLe_blo = null;
        private HoaDonBanSiBlo hDonBanSi_blo = null;
        private KhoBlo kho_blo = null;
        private MatHangBlo matHang_blo= null;
        private NhomQuyenBlo nhomQuyen_blo = null;
        private PhieuChiBlo phieuChi_blo = null;
        private PhieuDieuChinhKhoBlo phieuDieuChinhKho_blo = null;
        private PhieuKHDatHangBlo phieuKHDatHang_blo = null;
        private PhieuKHTraHangBlo phieuKHTraHang_blo = null;
        private PhieuThuBlo phieuThu_blo = null;
        private PhieuTraHangNCCBlo phieuTraHangNCC_blo = null;
        private TaiKhoanNhanVienBlo taiKhoanNhanVien_blo = null;
        private TaiKhoanOnlineBlo taiKhoanOnline_blo = null;
        private ChiTietTraHangNCCBlo ctTraHangNCC_blo = null;
        private CTDatHangNCCBlo ctDatHangNCC_blo = null;
        private CTNhapHangBlo ctNhapHang_blo = null;
        private HoaDonNhapHangBlo hoaDonNhapHang_blo = null;
        private LoaiHangBlo loaiHang_blo = null;

        private Data_LayHinhDataContext dt;
        private Helper helper = null;        
        #endregion
    
        #region "Thuộc tính và contructor"
        
        public Serviec_QLNhaSach()
        {
            ncc_blo = new NhaCungCapBlo();
            phieuDHNCC_blo = new PhieuDatHangNCCBlo();
            nhanvien_blo = new NhanVienBlo();
            khachhang_blo = new KhachHangBlo();
            ctdathangOnline_blo = new CTDatHangOnlineBlo();
            ctKHDatHang_blo = new CTKHDatHangBlo();
            ctDieuChinhKho_blo = new CTDieuChinhKhoBlo();
            ctHDBanLe_blo = new CTHDBanLeBlo();
            ctHDBanSi_blo = new CTHDBanSiBlo();
            ctKHTraHang_blo = new CTKHTraHangBlo();
            ctPhanQuyen_blo = new CTPhanQuyenBlo();
            datHangOnline_blo = new DatHangOnlineBlo();
            form_blo = new FormBlo();
            hDonBanLe_blo = new HoaDonBanLeBlo();
            hDonBanSi_blo = new HoaDonBanSiBlo();
            kho_blo = new KhoBlo();
            matHang_blo = new MatHangBlo();
            nhomQuyen_blo = new NhomQuyenBlo();
            phieuChi_blo = new PhieuChiBlo();
            phieuDieuChinhKho_blo = new PhieuDieuChinhKhoBlo();
            phieuKHDatHang_blo = new PhieuKHDatHangBlo();
            phieuKHTraHang_blo = new PhieuKHTraHangBlo();
            phieuThu_blo = new PhieuThuBlo();
            phieuTraHangNCC_blo = new PhieuTraHangNCCBlo();
            taiKhoanNhanVien_blo = new TaiKhoanNhanVienBlo();
            taiKhoanOnline_blo = new TaiKhoanOnlineBlo();
            ctTraHangNCC_blo = new ChiTietTraHangNCCBlo();
            ctDatHangNCC_blo = new CTDatHangNCCBlo();
            ctNhapHang_blo = new CTNhapHangBlo();
            hoaDonNhapHang_blo = new HoaDonNhapHangBlo();
            loaiHang_blo = new LoaiHangBlo();
            dt = new Data_LayHinhDataContext();
        }
        #endregion

        #region "I_Adapter"

        public string selectqueryByText(string cau_truy_van)
        {
            string kq = "";
            helper = new Helper();
            kq = helper.SelectQueryByText(cau_truy_van).GetXml();
            return kq;
        }

        public string selectqueryStoreProcedure(string Ten_Store,params SqlParameter[] Danh_Sach_Bien)
        {
            string kq = "";
            helper = new Helper();
            kq = helper.SelectQuery(Ten_Store, Danh_Sach_Bien).GetXml();
            return kq;
        }
        
        public byte[] Layhinh(string maMH)
        {
            var query = (from h in dt.MatHangs
                         where h.MaMH == maMH
                         select h.Hinh).FirstOrDefault();
            if (query != null)
                return query.ToArray();
            else
                return null;
        }

        public string BaoCaoXuatNhapTon(DateTime TuNgay, DateTime DenNgay, string MaKho, string MaMH)
        {
            string kq = "";
            helper = new Helper();
            SqlParameter[] par = new SqlParameter[4];
            par[0] = new SqlParameter("@TuNgay", TuNgay);
            par[1] = new SqlParameter("@DenNgay", DenNgay);
            par[2] = new SqlParameter("@MaKho", MaKho);
            par[3] = new SqlParameter("@MaMH", MaMH);

            kq = helper.SelectQuery("sp_QLXuatNhapTon",par).GetXml();
            return kq;
        }

        public string BaoCaoCongNo(DateTime TuNgay, DateTime DenNgay, string MaNCC, string MaKH,bool TrangThaiKH)
        {
            string kq = "";
            helper = new Helper();
            SqlParameter[] par = new SqlParameter[5];
            par[0] = new SqlParameter("@TuNgay", TuNgay);
            par[1] = new SqlParameter("@DenNgay", DenNgay);
            par[2] = new SqlParameter("@MaNCC", MaNCC);
            par[3] = new SqlParameter("@MaKH", MaKH);
            par[4] = new SqlParameter("@TrangThaiKH", TrangThaiKH);

            kq = helper.SelectQuery("sp_BCCongNo", par).GetXml();
            return kq;
        }

        public string BaoCaoDoanhThu(DateTime TuNgay, DateTime DenNgay)
        {
            string kq = "";
            helper = new Helper();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@ngaybatdau", TuNgay);
            par[1] = new SqlParameter("@ngayketthuc", DenNgay);

            kq = helper.SelectQuery("sp_BaoCaoDoanhThu", par).GetXml();
            return kq;
        }

        public bool Restore_Data(string filepath)
        {
            bool kiem_tra = false;//Neu ko thanh cong
            Helper help = new Helper("master");
            help.SelectQueryByText(filepath);
               if(help.Error == "")
                   kiem_tra = true;
            return kiem_tra;
        }
        #endregion

        #region "I_Nha Cung Cap"

        public bool InsertNCC(string MaNCC, string TenNCC, string DiaChiNCC, string SDT, string Email, double CongNo)
        {
            return ncc_blo.InsertNCC(MaNCC, TenNCC, DiaChiNCC, SDT, Email, CongNo);        
        }

        public bool UpdateNCC(string MaNCC, string TenNCC, string DiaChiNCC, string SDT, string Email, double CongNo)
        {
            return ncc_blo.UpdateNCC(MaNCC, TenNCC, DiaChiNCC, SDT, Email, CongNo);
        }

        public bool DeleteNCC(string MaNCC)
        {
            return ncc_blo.DeleteNCC(MaNCC);
        }

        public string LayDS_NhaCungCap()
        {
            string kq = "";
            kq = ncc_blo.LayDS_NhaCungCap().GetXml();
            return kq;
        }

        #endregion        

        #region "I_Nhan Vien"
        public bool InsertNV(string MaNV, string HoTen, string SDT, DateTime NgaySinh, string DiaChiNV, string CMND, string ChucVu)
        {
            return nhanvien_blo.InsertNV(MaNV, HoTen, SDT, NgaySinh, DiaChiNV, CMND, ChucVu);
        }

        public bool UpdateNV(string MaNV, string HoTen, string SDT, DateTime NgaySinh, string DiaChiNV, string CMND, string ChucVu)
        {
            return nhanvien_blo.UpdateNV(MaNV, HoTen, SDT, NgaySinh, DiaChiNV, CMND, ChucVu);
        }
        public bool DeleteNV(string MaNV)
        {
            return nhanvien_blo.DeleteNV(MaNV);
        }
        public string LayDS_NhanVien()
        {
            string kq = "";
            kq = nhanvien_blo.LayDS_NhanVien().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Khach Hang"
        public bool InsertKH(string Makh, string Hoten, string SDT, string DiaChi, string Email, int SoFax, double CongNo, string MaSoThue)
        {
            return khachhang_blo.InsertKH(Makh,Hoten,SDT,DiaChi,Email,SoFax,CongNo,MaSoThue);
        }

        public bool UpdateKH(string Makh, string Hoten, string SDT, string DiaChi, string Email, int SoFax, double CongNo, string MaSoThue)
        {
            return khachhang_blo.UpdateKH(Makh, Hoten, SDT, DiaChi, Email, SoFax, CongNo, MaSoThue);
        }
        public bool DeleteKH(string MaKH)
        {
            return khachhang_blo.DeleteKH(MaKH);
        }
        public string LayDS_KhachHang()
        {
            string kq = "";
            kq = khachhang_blo.LayDS_KhachHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Dat Hang Online"
        public bool InsertCTDHOL(string MaDHOL, string MaMH, int SoLuong, double DonGia, float KhuyenMai,double ThanhTien)
        {
            return ctdathangOnline_blo.InsertCTDHOL(MaDHOL, MaMH, SoLuong, DonGia, KhuyenMai,ThanhTien);
        }

        public bool UpdateCTDHOL(string MaDHOL, string MaMH, int SoLuong, double DonGia, float KhuyenMai,double ThanhTien)
        {
            return ctdathangOnline_blo.UpdateCTDHOL(MaDHOL, MaMH, SoLuong, DonGia, KhuyenMai,ThanhTien);
        }
        public bool DeleteCTDHOL(string MaDHOL, string MaMH)
        {
            return ctdathangOnline_blo.DeleteCTDHOL(MaDHOL, MaMH);
        }
        public string LayDS_CTDatHangOnline()
        {
            string kq = "";
            kq = ctdathangOnline_blo.LayDS_CTDatHangOnline().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Nhap Hang"
        public bool InsertCTNH(string maMH, string maHDNH, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            return ctNhapHang_blo.InsertCTNH(maMH, maHDNH, soLuong, donGia, chietKhau, thanhTien);
        }

        public bool UpdateCTNH(string maMH, string maHDNH, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            return ctNhapHang_blo.UpdateCTNH(maMH, maHDNH, soLuong, donGia, chietKhau, thanhTien);
        }
        public bool DeleteCTNH(string MaMH, string MaHDNH)
        {
            return ctNhapHang_blo.DeleteCTNH(MaMH, MaHDNH);
        }
        public string LayDS_CTNhapHang()
        {
            string kq = "";
            kq = ctNhapHang_blo.LayDS_CTNhapHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Khach Hang Dat Hang"
        public bool InsertCTKHDatHang(string MaMH, string MaKHDH, int SoLuong, string DVT, double DonGia, float ChietKhau, double ThanhTien, bool DaGiao)
        {
            return ctKHDatHang_blo.InsertCTKHDatHang(MaMH, MaKHDH, SoLuong, DVT, DonGia, ChietKhau, ThanhTien, DaGiao);
        }

        public bool UpdateCTKHDatHang(string MaMH, string MaKHDH, int SoLuong, string DVT, double DonGia, float ChietKhau, double ThanhTien, bool DaGiao)
        {
            return ctKHDatHang_blo.UpdateCTKHDatHang(MaMH, MaKHDH, SoLuong, DVT, DonGia, ChietKhau, ThanhTien, DaGiao);
        }
        public bool DeleteCTKHDatHang(string MaMH, string MaKHDH)
        {
            return ctKHDatHang_blo.DeleteCTKHDatHang(MaMH, MaKHDH);
        }
        public string LaLayDS_CTKHDatHang()
        {
            string kq = "";
            kq = ctKHDatHang_blo.LayDS_CTKHDatHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Khach Hang Tra Hang"
        public bool InsertCTKHTraHang(string MaMH, string MaKHTh, int SoLuong, double DonGia, float ChietKhau, double ThanhTien)
        {
            return ctKHTraHang_blo.InsertCTKHTraHang(MaMH, MaKHTh, SoLuong, DonGia, ChietKhau, ThanhTien);
        }

        public bool UpdateCTKHTraHang(string MaMH, string MaKHTh, int SoLuong, double DonGia, float ChietKhau, double ThanhTien)
        {
            return ctKHTraHang_blo.UpdateCTKHTraHang(MaMH, MaKHTh, SoLuong, DonGia, ChietKhau, ThanhTien);
        }
        public bool DeleteCTKHTraHang(string MaMH, string MaKHTH)
        {
            return ctKHTraHang_blo.DeleteCTKHTraHang(MaMH,MaKHTH);
        }
        public string LayDS_CTKHTraHang()
        {
            string kq = "";
            kq = ctKHTraHang_blo.LayDS_CTKHTraHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Tra Hang NCC"
        public bool InsertCTTraHangNCC(string maMH, string maTHNCC, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            return ctTraHangNCC_blo.InsertCTTraHangNCC(maMH, maTHNCC, soLuong, donGia, chietKhau, thanhTien);
        }

        public bool UpdateCTTraHangNCC(string maMH, string maTHNCC, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            return ctTraHangNCC_blo.UpdateCTTraHangNCC(maMH, maTHNCC, soLuong, donGia, chietKhau, thanhTien);
        }
        public bool DeleteCTTraHangNCC(string MaMH, string MaTHNCC)
        {
            return ctTraHangNCC_blo.DeleteCTTraHangNCC(MaMH, MaTHNCC);
        }
        public string LayDS_ChiTietTraHangNCC()
        {
            string kq = "";
            kq = ctTraHangNCC_blo.LayDS_ChiTietTraHangNCC().GetXml();
            return kq;
        }
        #endregion

        #region "I_Chi Tiet Dat Hang NCC"
        public bool InsertCTDHNCC(string maMH, string maDHNCC, int soLuong, string dVT, double donGia, float chietKhau, double thanhTien, bool daGiao)
        {
            return ctDatHangNCC_blo.InsertCTDHNCC(maMH, maDHNCC, soLuong, dVT, donGia, chietKhau, thanhTien, daGiao);
        }

        public bool UpdateCTDHNCC(string maMH, string maDHNCC, int soLuong, string dVT, double donGia, float chietKhau, double thanhTien, bool daGiao)
        {
            return ctDatHangNCC_blo.UpdateCTDHNCC(maMH, maDHNCC, soLuong, dVT, donGia, chietKhau, thanhTien, daGiao);
        }
        public bool DeleteCTDHNCC(string MaMH, string maDHNCC)
        {
            return ctDatHangNCC_blo.DeleteCTDHNCC(MaMH, maDHNCC);
        }
        public string LayDS_CTDatHangNCC()
        {
            string kq = "";
            kq = ctDatHangNCC_blo.LayDS_CTDatHangNCC().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Dieu Chinh Kho"
        public bool InsertCTDieuChinhKho(string MaPDCK, string MaMH, int SoLuong, double DonGia, double ThanhTien)
        {
            return ctDieuChinhKho_blo.InsertCTDieuChinhKho(MaPDCK, MaMH, SoLuong, DonGia, ThanhTien);
        }

        public bool UpdateCTDieuChinhKho(string MaPDCK, string MaMH, int SoLuong, double DonGia, double ThanhTien)
        {
            return ctDieuChinhKho_blo.UpdateCTDieuChinhKho(MaPDCK, MaMH, SoLuong, DonGia, ThanhTien);
        }
        public bool DeleteCTDieuChinhKho(string MaPDCK, string MaMH)
        {
            return ctDieuChinhKho_blo.DeleteCTDieuChinhKho(MaPDCK, MaMH);
        }
        public string LayDS_CTPDCKho()
        {
            string kq = "";
            kq = ctDieuChinhKho_blo.LayDS_CTPDCKho().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Hoa Don Ban Le"
        public bool InsertCTHDBL(string MaMH, string MaHDBL, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            return ctHDBanLe_blo.InsertCTHDBL(MaMH, MaHDBL, DonGia, SoLuong, ChietKhau, ThanhTien);
        }

        public bool UpdateCTHDBL(string MaMH, string MaHDBL, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            return ctHDBanLe_blo.UpdateCTHDBL(MaMH, MaHDBL, DonGia, SoLuong, ChietKhau, ThanhTien);
        }
        public bool DeleteCTHDBL(string MaMH, string MaHDBL)
        {
            return ctHDBanLe_blo.DeleteCTHDBL(MaMH, MaHDBL);
        }
        public string LayDS_CTHDBanLe()
        {
            string kq = "";
            kq = ctHDBanLe_blo.LayDS_CTHDBanLe().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Hoa Don Ban Si"
        public bool InsertCTHDBS(string MaMH, string MaHDBS, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            return ctHDBanSi_blo.InsertCTHDBS(MaMH, MaHDBS, DonGia, SoLuong, ChietKhau, ThanhTien);
        }

        public bool UpdateCTHDBS(string MaMH, string MaHDBS, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            return ctHDBanSi_blo.UpdateCTHDBS(MaMH, MaHDBS, DonGia, SoLuong, ChietKhau, ThanhTien);
        }
        public bool DeleteCTHDBS(string MaMH, string MaHDBS)
        {
            return ctHDBanSi_blo.DeleteCTHDBS(MaMH, MaHDBS);
        }
        public string LayDS_CTHDBanSi()
        {
            string kq = "";
            kq = ctHDBanSi_blo.LayDS_CTHDBanSi().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Chi Tiet Phan Quyen"
        public bool InsertCTPQ(string MaNhom, string MaForm, bool Them, bool Xoa, bool Sua, bool ToanQuyen)
        {
            return ctPhanQuyen_blo.InsertCTPQ(MaNhom, MaForm, Them, Xoa, Sua, ToanQuyen);
        }

        public bool UpdateCTPQ(string MaNhom, string MaForm, bool Them, bool Xoa, bool Sua, bool ToanQuyen)
        {
            return ctPhanQuyen_blo.UpdateCTPQ(MaNhom, MaForm, Them, Xoa, Sua, ToanQuyen);
        }
        public bool DeleteCTPQ(string MaNhom, string MaForm)
        {
            return ctPhanQuyen_blo.DeleteCTPQ(MaNhom, MaForm);
        }
        public string LayDS_CTPhanQuyen()
        {
            string kq = "";
            kq = ctPhanQuyen_blo.LayDS_CTPhanQuyen().GetXml();
            return kq;
        }
        #endregion                               

        #region "I_Dat Hang Online"
        public bool InsertDHOL(string MaDHOL, string MaTKOL, DateTime NgayDatHang, string Hinhthucthanhtoan, string Trangthai, double Tongtien)
        {
            return datHangOnline_blo.InsertDHOL(MaDHOL, MaTKOL, NgayDatHang, Hinhthucthanhtoan, Trangthai, Tongtien);
        }

        public bool UpdateDHOL(string MaDHOL, string MaTKOL, DateTime NgayDatHang, string Hinhthucthanhtoan, string Trangthai, double Tongtien)
        {
            return datHangOnline_blo.UpdateDHOL(MaDHOL, MaTKOL, NgayDatHang, Hinhthucthanhtoan, Trangthai, Tongtien);
        }
        public bool DeleteDHOL(string MaDHOL)
        {
            return datHangOnline_blo.DeleteDHOL(MaDHOL);
        }
        public string LayDS_DatHangOnline()
        {
            string kq = "";
            kq = datHangOnline_blo.LayDS_DatHangOnline().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Form"
        public bool InsertForm(string MaForm, string TenForm)
        {
            return form_blo.InsertForm(MaForm, TenForm);
        }

        public bool UpdateForm(string MaForm, string TenForm)
        {
            return form_blo.UpdateForm(MaForm, TenForm);
        }
        public bool DeleteForm(string MaForm)
        {
            return form_blo.DeleteForm(MaForm);
        }
        public string LayDS_Form()
        {
            string kq = "";
            kq = form_blo.LayDS_Form().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Hoa Don Ban Le"
        public bool InsertHDBL(string MaHDBL, string MaNV,string MaKho, DateTime NgayBanLe, string ChungTubanLe, float VAT, double TongThanhTien,string Quay)
        {
            return hDonBanLe_blo.InsertHDBL(MaHDBL, MaNV,MaKho, NgayBanLe, ChungTubanLe, VAT, TongThanhTien,Quay);
        }

        public bool UpdateHDBL(string MaHDBL, string MaNV,string MaKho, DateTime NgayBanLe, string ChungTubanLe, float VAT, double TongThanhTien,string Quay)
        {
            return hDonBanLe_blo.UpdateHDBL(MaHDBL, MaNV,MaKho, NgayBanLe, ChungTubanLe, VAT, TongThanhTien,Quay);
        }
        public bool DeleteHDBL(string MaHDBL)
        {
            return hDonBanLe_blo.DeleteHDBL(MaHDBL);
        }
        public string LayDS_HoaDonBanLe()
        {
            string kq = "";
            kq = hDonBanLe_blo.LayDS_HoaDonBanLe().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Hoa Don Ban Si"
        public bool InsertHDBS(string MaHDBS, string MaKho, string MaKH, string MaNV, string NguoiMua, DateTime NgayBanSi, string ChungTuBanSi, string GhiChuBS, string DiaChiGiao, float VAT, double TongThanhTien, double SoTienDaTra, double SoTienConLai, DateTime NgayHenThanhToan)
        {
            return hDonBanSi_blo.InsertHDBS(MaHDBS, MaKho, MaKH, MaNV, NguoiMua, NgayBanSi, ChungTuBanSi, GhiChuBS, DiaChiGiao, VAT, TongThanhTien, SoTienDaTra, SoTienConLai, NgayHenThanhToan);
        }

        public bool UpdateHDBS(string MaHDBS, string MaKho, string MaKH, string MaNV, string NguoiMua, DateTime NgayBanSi, string ChungTuBanSi, string GhiChuBS, string DiaChiGiao, float VAT, double TongThanhTien, double SoTienDaTra, double SoTienConLai, DateTime NgayHenThanhToan)
        {
            return hDonBanSi_blo.UpdateHDBS(MaHDBS, MaKho, MaKH, MaNV, NguoiMua, NgayBanSi, ChungTuBanSi, GhiChuBS, DiaChiGiao, VAT, TongThanhTien, SoTienDaTra, SoTienConLai, NgayHenThanhToan);
        }
        public bool DeleteHDBS(string MaHDBS)
        {
            return hDonBanSi_blo.DeleteHDBS(MaHDBS);
        }
        public string LayDS_HoaDonBanSi()
        {
            string kq = "";
            kq = hDonBanSi_blo.LayDS_HoaDonBanSi().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Hoa Don Nhap Hang"
        public bool InsertHDNH(string maHDNH, string maNCC, string maKho, string maNV, DateTime ngayNhap, string chungTuNH, float vAT, double tongThanhTien, double soTienDaDua, double soTienConLai, DateTime ngayHenThanhToan)
        {
            return hoaDonNhapHang_blo.InsertHDNH(maHDNH, maNCC, maKho, maNV, ngayNhap, chungTuNH, vAT, tongThanhTien, soTienDaDua, soTienConLai, ngayHenThanhToan);
        }

        public bool UpdateHDNH(string maHDNH, string maNCC, string maKho, string maNV, DateTime ngayNhap, string chungTuNH, float vAT, double tongThanhTien, double soTienDaDua, double soTienConLai, DateTime ngayHenThanhToan)
        {
            return hoaDonNhapHang_blo.UpdateHDNH(maHDNH, maNCC, maKho, maNV, ngayNhap, chungTuNH, vAT, tongThanhTien, soTienDaDua, soTienConLai, ngayHenThanhToan);
        }
        public bool DeleteHDNH(string MaHDNH)
        {
            return hoaDonNhapHang_blo.DeleteHDNH(MaHDNH);
        }
        public string LayDS_HoaDonNhapHang()
        {
            string kq = "";
            kq = hoaDonNhapHang_blo.LayDS_HoaDonNhapHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Kho"
        public bool InsertKho(string MaKho, string TenKho, int TongSoLuongTon)
        {
            return kho_blo.InsertKho(MaKho, TenKho, TongSoLuongTon);
        }

        public bool UpdateKho(string MaKho, string TenKho, int TongSoLuongTon)
        {
            return kho_blo.UpdateKho(MaKho, TenKho, TongSoLuongTon);
        }
        public bool DeleteKho(string MaKho)
        {
            return kho_blo.DeleteKho(MaKho);
        }
        public string LayDS_Kho()
        {
            string kq = "";
            kq = kho_blo.LayDS_Kho().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Loai Hang"
        public bool InsertLoaiHang(string MaLoai, string TenLoai)
        {
            return loaiHang_blo.InsertLoaiHang(MaLoai, TenLoai);
        }

        public bool UpdateLoaiHang(string MaLoai, string TenLoai)
        {
            return loaiHang_blo.UpdateLoaiHang(MaLoai, TenLoai);
        }
        public bool DeleteLoaiHang(string MaLoai)
        {
            return loaiHang_blo.DeleteLoaiHang(MaLoai);
        }
        public string LayDS_LoaiHang()
        {
            string kq = "";
            kq = loaiHang_blo.LayDS_LoaiHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Mat Hang"
        public bool InsertMatHang(string mamh, string maloai, string tenmh, double dgn, double dgs, double dgl, float km, string nhasx, string tg, string namsx, string dausach, string dvt, int slDauKy, int slHienCo, byte[] hinh)
        {
            return matHang_blo.InsertMatHang(mamh, maloai, tenmh, dgn, dgs, dgl, km, nhasx, tg, namsx, dausach, dvt, slDauKy, slHienCo, hinh);
        }

        public bool UpdateMatHang(string mamh, string maloai, string tenmh, double dgn, double dgs, double dgl, float km, string nhasx, string tg, string namsx, string dausach, string dvt, int slDauKy, int slHienCo, byte[] hinh)
        {
            return matHang_blo.UpdateMatHang(mamh, maloai, tenmh, dgn, dgs, dgl, km, nhasx, tg, namsx, dausach, dvt, slDauKy, slHienCo, hinh);
        }
        public bool DeleteMatHang(string MaMH)
        {
            return matHang_blo.DeleteMatHang(MaMH);
        }
        public string LayDS_MatHang()
        {
            string kq = "";
            kq = matHang_blo.LayDS_MatHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Nhom Quyen"
        public bool InsertNhonQuyen(string MaNhom, string TenNhom)
        {
            return nhomQuyen_blo.InsertNhonQuyen(MaNhom, TenNhom);
        }

        public bool UpdateNhonQuyen(string MaNhom, string TenNhom)
        {
            return nhomQuyen_blo.UpdateNhonQuyen(MaNhom, TenNhom);
        }
        public bool DeleteNhomQuyen(string MaNhom)
        {
            return nhomQuyen_blo.DeleteNhomQuyen(MaNhom);
        }
        public string LayDS_NhomQuyen()
        {
            string kq = "";
            kq = nhomQuyen_blo.LayDS_NhomQuyen().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Chi"
        public bool InsertPhieuChi(string mapc, string mancc, string maNV, DateTime ngaychi, string khoanmucchi, string lydochi, double sotienchi, string chungtupc)
        {
            return phieuChi_blo.InsertPhieuChi(mapc, mancc,maNV, ngaychi, khoanmucchi, lydochi, sotienchi, chungtupc);
        }

        public bool UpdatePhieuChi(string mapc, string mancc, DateTime ngaychi, string khoanmucchi, string lydochi, double sotienchi, string chungtupc)
        {
            return phieuChi_blo.UpdatePhieuChi(mapc, mancc, ngaychi, khoanmucchi, lydochi, sotienchi, chungtupc);
        }
        public bool DeletePhieuChi(string MaPC)
        {
            return phieuChi_blo.DeletePhieuChi(MaPC);
        }
        public string LayDS_PhieuChi()
        {
            string kq = "";
            kq = phieuChi_blo.LayDS_PhieuChi().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Dieu Chinh Kho"
        public bool InsertPDCKho(string ma, DateTime ngaydc, string manvxuat, string manvnhan, string makhoxuat, string makhonhan, double tongtien)
        {
            return phieuDieuChinhKho_blo.InsertPDCKho(ma, ngaydc, manvxuat, manvnhan, makhoxuat, makhonhan, tongtien);
        }

        public bool UpdatePDCKho(string ma, DateTime ngaydc, string manvxuat, string manvnhan, string makhoxuat, string makhonhan, double tongtien)
        {
            return phieuDieuChinhKho_blo.UpdatePDCKho(ma, ngaydc, manvxuat, manvnhan, makhoxuat, makhonhan, tongtien);
        }
        public bool DeletePDCKho(string MaPDCK)
        {
            return phieuDieuChinhKho_blo.DeletePDCKho(MaPDCK);
        }
        public string LayDS_PDCKho()
        {
            string kq = "";
            kq = phieuDieuChinhKho_blo.LayDS_PDCKho().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Khach Hang Dat Hang"
        public bool InsertPhieuKHDatHang(string makhdh, string makho, string makh, string manv, string sochungtu, DateTime ngaythangdh, string diachi, string ghichudh, double tongtien, double tamung, double conlai, DateTime ngaybangiao)
        {
            return phieuKHDatHang_blo.InsertPhieuKHDatHang(makhdh, makho, makh, manv, sochungtu, ngaythangdh, diachi, ghichudh, tongtien, tamung, conlai, ngaybangiao);
        }

        public bool UpdatePhieuKHDatHang(string makhdh, string makho, string makh, string manv, string sochungtu, DateTime ngaythangdh, string diachi, string ghichudh, double tongtien, double tamung, double conlai, DateTime ngaybangiao)
        {
            return phieuKHDatHang_blo.UpdatePhieuKHDatHang(makhdh, makho, makh, manv, sochungtu, ngaythangdh, diachi, ghichudh, tongtien, tamung, conlai, ngaybangiao);
        }
        public bool DeletePhieuKHDatHang(string maKHDH)
        {
            return phieuKHDatHang_blo.DeletePhieuKHDatHang(maKHDH);
        }
        public string LayDS_PhieuKHDatHang()
        {
            string kq = "";
            kq = phieuKHDatHang_blo.LayDS_PhieuKHDatHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Khach Hang Tra Hang"
        public bool InsertPhieuKHTraHang(string makhth, string manv, string makho,string maKH, string nguoitra, string masothue, string diachi, DateTime ngaytra, string chungtutra, string ghichu, double tongthanhtien)
        {
            return phieuKHTraHang_blo.InsertPhieuKHTraHang(makhth, manv, makho,maKH, nguoitra, masothue, diachi, ngaytra, chungtutra, ghichu, tongthanhtien);
        }

        public bool UpdatePhieuKHTraHang(string makhth, string manv, string makho,string maKH, string nguoitra, string masothue, string diachi, DateTime ngaytra, string chungtutra, string ghichu, double tongthanhtien)
        {
            return phieuKHTraHang_blo.UpdatePhieuKHTraHang(makhth, manv, makho,maKH, nguoitra, masothue, diachi, ngaytra, chungtutra, ghichu, tongthanhtien);
        }
        public bool DeletePhieuKHTraHang(string maKHTH)
        {
            return phieuKHTraHang_blo.DeletePhieuKHTraHang(maKHTH);
        }
        public string LayDS_PhieuKHTraHang()
        {
            string kq = "";
            kq = phieuKHTraHang_blo.LayDS_PhieuKHTraHang().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Dat Hang Nha Cung Cap"
        public bool InsertPhieuDHNCC(string MaDHNCC, string MaNV, string MaKHo, string MaNCC, string SoChungTu, DateTime NgayThang, string GhiChu, double TongDonHang, double TamUng, double ConLai, DateTime NgayBanGiao)
        {
            return phieuDHNCC_blo.InsertPhieuDHNCC(MaDHNCC, MaNV, MaKHo, MaNCC, SoChungTu, NgayThang, GhiChu, TongDonHang, TamUng, ConLai, NgayBanGiao);
        }

        public bool UpdatePhieuDHNCC(string MaDHNCC, string MaNV, string MaKHo, string MaNCC, string SoChungTu, DateTime NgayThang, string GhiChu, double TongDonHang, double TamUng, double ConLai, DateTime NgayBanGiao)
        {
            return phieuDHNCC_blo.UpdatePhieuDHNCC(MaDHNCC, MaNV, MaKHo, MaNCC, SoChungTu, NgayThang, GhiChu, TongDonHang, TamUng, ConLai, NgayBanGiao);
        }

        public bool DeletePhieuDHNCC(string MaDHNCC)
        {
            return phieuDHNCC_blo.DeletePhieuDHNCC(MaDHNCC);
        }
        public string LayDS_PhieuDatHangNCC()
        {
            string kq = "";
            kq = phieuDHNCC_blo.LayDS_PhieuDatHangNCC().GetXml();
            return kq;
        }
        #endregion

        #region "I_Phieu Tra Hang Nha Cung Cap"
        public bool InsertPhieuTraHangNCC(string maTHNCC, string maNV, string maKho, string maNCC, string maSoThue, DateTime ngayTra, string nguoiTra, string chungTuTra, string ghiChuTH, double tongThanhTien)
        {
            return phieuTraHangNCC_blo.InsertPhieuTraHangNCC(maTHNCC, maNV, maKho, maNCC, maSoThue, ngayTra, nguoiTra, chungTuTra, ghiChuTH, tongThanhTien);
        }

        public bool UpdatePhieuTraHangNCC(string maTHNCC, string maNV, string maKho, string maNCC, string maSoThue, DateTime ngayTra, string nguoiTra, string chungTuTra, string ghiChuTH, double tongThanhTien)
        {
            return phieuTraHangNCC_blo.UpdatePhieuTraHangNCC(maTHNCC, maNV, maKho, maNCC, maSoThue, ngayTra, nguoiTra, chungTuTra, ghiChuTH, tongThanhTien);
        }
        public bool DeletePhieuTraHangNCC(string MaTHNCC)
        {
            return phieuTraHangNCC_blo.DeletePhieuTraHangNCC(MaTHNCC);
        }
        public string LayDS_PhieuTraHangNCC()
        {
            string kq = "";
            kq = phieuTraHangNCC_blo.LayDS_PhieuTraHangNCC().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Phieu Thu"
        public bool InsertPhieuThu(string mapt, string makh, string maNV, DateTime ngaythu, string khoanmucthu, string lydothu, double sotienthu, string chungtupt)
        {
            return phieuThu_blo.InsertPhieuThu(mapt, makh,maNV, ngaythu, khoanmucthu, lydothu, sotienthu, chungtupt);
        }

        public bool UpdatePhieuThu(string mapt, string makh, DateTime ngaythu, string khoanmucthu, string lydothu, double sotienthu, string chungtupt)
        {
            return phieuThu_blo.UpdatePhieuThu(mapt, makh, ngaythu, khoanmucthu, lydothu, sotienthu, chungtupt);
        }
        public bool DeletePhieuThu(string MaPT)
        {
            return phieuThu_blo.DeletePhieuThu(MaPT);
        }
        public string LayDS_PhieuTHu()
        {
            string kq = "";
            kq = phieuThu_blo.LayDS_PhieuTHu().GetXml();
            return kq;
        }
        #endregion                               

        #region "I_Tai Khoan Nhan Vien"
        public bool InsertTKNV(string MaTKNV, string MaNhom, string MaNV, string MatKhau)
        {
            return taiKhoanNhanVien_blo.InsertTKNV(MaTKNV, MaNhom, MaNV, MatKhau);
        }

        public bool UpdateTKNV(string MaTKNV, string MaNhom, string MaNV, string MatKhau)
        {
            return taiKhoanNhanVien_blo.UpdateTKNV(MaTKNV, MaNhom, MaNV, MatKhau);
        }
        public bool DeleteTKNV(string MaTKNV)
        {
            return taiKhoanNhanVien_blo.DeleteTKNV(MaTKNV);
        }
        public string LayDS_TaiKhoanNhanVien()
        {
            string kq = "";
            kq = taiKhoanNhanVien_blo.LayDS_TaiKhoanNhanVien().GetXml();
            return kq;
        }
        #endregion                       

        #region "I_Tai Khoan Online"
        public bool InsertTKOL(string MaTKOL, string TenDangNhap, string MatKhau, string DiaChi, string DienThoai ,string Email, DateTime NgayDangKy)
        {
            return taiKhoanOnline_blo.InsertTKOL(MaTKOL, TenDangNhap, MatKhau, DiaChi, DienThoai, Email, NgayDangKy);
        }

        public bool UpdateTKOL(string MaTKOL, string TenDangNhap, string MatKhau, string DiaChi, string DienThoai, string Email, DateTime NgayDangKy)
        {
            return taiKhoanOnline_blo.UpdateTKOL(MaTKOL, TenDangNhap, MatKhau, DiaChi, DienThoai, Email, NgayDangKy);
        }
        public bool DeleteTKOL(string MaTKOL)
        {
            return taiKhoanOnline_blo.DeleteTKOL(MaTKOL);
        }
        public string LayDS_TaiKhoanOnline()
        {
            string kq = "";
            kq = taiKhoanOnline_blo.LayDS_TaiKhoanOnline().GetXml();
            return kq;
        }
        #endregion                                                           
    }
}
